2011年7月11日 — Here's how you read a file, and then write to it (overwriting any existing data), without closing and reopening: with open(filename, r+) ...
To open the file, use the built-in open() function. The open() function returns a file object, which has a read() method for reading the content of the file ...